package com.study.rabbitmq.dead;

import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import com.study.rabbitmq.utils.RabbitMqUtil;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * @author ：黄淼淳
 * @description：死信队列
 * @date ：2021/12/8 19:13
 */
public class Comsume2 {

     public static final String DEAD_EXCHANGE = "dead_exchange";
    private static final String DEAD_QUEUE = "dead_queue";

    public static void main(String[] args) throws IOException {
         Channel channel = RabbitMqUtil.getChannel();
         DeliverCallback deliverCallback = (consumeTag, message) -> {
             System.out.println("死信消费者接收消息：" + new String(message.getBody(), StandardCharsets.UTF_8));
         };
         CancelCallback cancelCallback = (consumeTag) -> {
         };
         System.out.println("死信消费者等待接收消息。。。。。。");
         channel.basicConsume(DEAD_QUEUE,true, deliverCallback, cancelCallback);
     }


}
